package com.yituo.mjworld.mvc.action.admin;

import com.yituo.mjworld.core.annotation.Check;
import com.yituo.mjworld.core.web.core.MyHttpRequest;
import com.yituo.mjworld.core.web.core.MyHttpResponse;
import com.yituo.mjworld.mvc.action.IBaseAction;
import com.yituo.mjworld.mvc.entity.web.WebReturnRequest;
import com.yituo.mjworld.mvc.form.QueryForm;
import com.yituo.mjworld.mvc.service.impl.ReturnRequestServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 退货请求处理模块
 */
@Component
public class ReturnRequestAction implements IBaseAction {

  @Autowired
  ReturnRequestServiceImpl returnRequestService;

  /**
   * 获取退单列表
   *
   * @param req
   * @param res
   * @throws IOException
   */
  @Override
  public void getList(MyHttpRequest req, MyHttpResponse res) throws IOException {
    QueryForm form = (QueryForm) req.getForm();
    res.success(returnRequestService.getList(form));
  }

  /**
   * 删除订单
   *
   * @param req
   * @param res
   * @throws IOException
   */
  @Override
  public void delete(MyHttpRequest req, MyHttpResponse res) throws IOException {

  }

  /**
   * 保存或者更新退单记录
   *
   * @param req
   * @param res
   * @throws IOException
   */
  @Override
  @Check(form= WebReturnRequest.class)
  public void saveOrUpdate(MyHttpRequest req, MyHttpResponse res) throws IOException {
    res.success(returnRequestService.saveOrUpdate(req.getForm()));
  }
}
